package com.whfc.wxmp.api.emp.service.impl;

import com.whfc.common.exception.BizException;
import com.whfc.common.face.aiot.AiotApiResult;
import com.whfc.common.face.aiot.AiotCode;
import com.whfc.common.face.aiot.AiotFaceApi;
import com.whfc.common.file.FileHandler;
import com.whfc.common.file.FilePathConfig;
import com.whfc.common.result.*;
import com.whfc.common.util.ImageUtil;
import com.whfc.common.util.RandomUtil;
import com.whfc.emp.dto.*;
import com.whfc.emp.entity.AppTrainingCategory;
import com.whfc.emp.param.*;
import com.whfc.emp.service.*;
import com.whfc.entity.dto.WxDeviceBindCheckDTO;
import com.whfc.fuum.entity.WxUser;
import com.whfc.fuum.service.SysDeptService;
import com.whfc.wxmp.api.base.service.WxOptionService;
import com.whfc.wxmp.api.emp.service.WxEmpService;
import com.whfc.wxmp.api.emp.service.WxTrainingService;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @Description:
 * @author: xugcheng
 * @version: 1.0
 * @date: 2019/8/27 9:15
 */
@Service
public class WxTrainingServiceImpl implements WxTrainingService {


    //    @Autowired
    @DubboReference(interfaceClass = AppTrainingService.class, version = "1.0.0", timeout = 5000)
    private AppTrainingService appTrainingService;
    @DubboReference(interfaceClass = AppTrainingCategoriesService.class, version = "1.0.0", timeout = 5000)
    private AppTrainingCategoriesService appTrainingCategoriesService;
    @DubboReference(interfaceClass = AppTrainingQuestionsService.class, version = "1.0.0", timeout = 5000)
    private AppTrainingQuestionsService appTrainingQuestionsService;
    @DubboReference(interfaceClass = AppExamPaperService.class, version = "1.0.0", timeout = 5000)
    private AppExamPaperService appExamPaperService;
    @DubboReference(interfaceClass = AppTrainingUserAnswerService.class, version = "1.0.0", timeout = 5000)
    private AppTrainingUserAnswerService appTrainingUserAnswerService;
    @DubboReference(interfaceClass = AppTrainingUserProgressService.class, version = "1.0.0", timeout = 5000)
    private AppTrainingUserProgressService appTrainingUserProgressService;
    @DubboReference(interfaceClass = AppTrainingBannerService.class, version = "1.0.0", timeout = 5000)
    private AppTrainingBannerService appTrainingBannerService;
    @DubboReference(interfaceClass = AppExamRecordService.class, version = "1.0.0", timeout = 5000)
    private AppExamRecordService appExamRecordService;


    @Override
    public List<AppTrainingCategory> categoryList() {
        return appTrainingCategoriesService.simpleList();
    }

    @Override
    public PageData<AppTrainingDTO> getTrainingList(AppTrainingListParam param) {
        return appTrainingService.getTrainingList(param);
    }

    @Override
    public PageData<AppTrainingQuestionsDTO> questionList(AppTrainingQuestionListParam param) {
        return appTrainingQuestionsService.list(param);
    }

    @Override
    public PageData<AppExamPaperDTO> examList(AppExamPaperListParam reqParam) {
        return appExamPaperService.list(reqParam);
    }

    @Override
    public PageData<AppExamPaperQuestionDTO> examQuestionList(AppExamPaperQuestionListParam reqParam) {
        return appExamPaperService.examQuestionList(reqParam);
    }

    @Override
    public Result trainingAnswer(AppTrainingAnswerAddParam reqParam) {
        appTrainingUserAnswerService.add(reqParam);
        return ResultUtil.success("提交成功");
    }

    @Override
    public Result trainingUserProgress(AppTrainingUserProgressListParam reqParam) {
        return ResultUtil.success(appTrainingUserProgressService.list(reqParam));
    }

    @Override
    public List<AppTrainingBannerDTO> bannerList() {
        return appTrainingBannerService.getTrainingBannerList();
    }

    @Override
    public PageData<AppExamRecordDTO> examRecordPage(AppExamRecordListParam request) {
        request.setUserId(request.getUserId());
        return appExamRecordService.list(request);
    }

    @Override
    public Result examing(AppExamRecordAddParam request) {
        return appExamRecordService.add(request);
    }


}
